package imgboard;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;


public class DeleteController extends AbstractController {
    private ImgMgr imgMgr;
    private String successView;

    public String getSuccessView() {
        return successView;
    }

    public void setSuccessView(String successView) {
        this.successView = successView;
    }  
    
    public ImgMgr getImgMgr() {
        return imgMgr;
    }

    public void setImgMgr(ImgMgr imgMgr) {
        this.imgMgr = imgMgr;
    }

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        System.out.println("DeleteController");
        
        int ino = Integer.parseInt(request.getParameter("ino"));
        
        ModelAndView mav = new ModelAndView();
        mav.setViewName(this.successView); 
        
        boolean flag = imgMgr.delete(ino);
        
        mav.addObject("msg", flag);
        
        return mav;
    }

    
}
